package org.darcy.controller.work;

import org.darcy.entity.work.WorkFlowObject;
import org.darcy.framework.constant.SysConstant;
import org.darcy.framework.model.R;
import org.darcy.service.business.BusinessContractService;
import org.darcy.service.business.BusinessFinancialBillService;
import org.darcy.service.business.BusinessFinancialReceivedService;
import org.darcy.service.check.CheckCollectService;
import org.darcy.service.check.CheckDeliveryService;
import org.darcy.service.check.CheckLibAnalysisService;
import org.darcy.service.check.CheckPlanService;
import org.darcy.service.check.CheckReasonService;
import org.darcy.service.flow.FlowLeaveCompanyService;
import org.darcy.service.work.WorkService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;

@Tag(name = "WorkFlow接口：工作流数据")
@RestController
@RequestMapping(value = "/work")
@Slf4j
public class WorkFlowController {

	@Autowired
	private WorkService WorkService;

	@Autowired
	private CheckPlanService CheckPlanService;

	@Autowired
	private CheckReasonService CheckReasonService;

	@Autowired
	private BusinessContractService BusinessContractService;

	@Autowired
	private BusinessFinancialReceivedService BusinessFinancialReceivedService;

	@Autowired
	private BusinessFinancialBillService BusinessFinancialBillService;

	@Autowired
	private CheckDeliveryService CheckDeliveryService;
	
	@Autowired
	private CheckCollectService CheckCollectService;
	
	@Autowired
	private CheckLibAnalysisService CheckLibAnalysisService;
	
	@Autowired
	private FlowLeaveCompanyService FlowLeaveCompanyService;

	@Operation(summary = "工作流业务数据")
	@GetMapping("/getBusinessData")
	public R getBusinessData(Integer id, String type, Integer index) {
		//log.debug("{}-工作流业务数据", info_prefix);
		WorkFlowObject data = null;
		switch (type) {
		case SysConstant.FormType.LeaveCompany:
			data = FlowLeaveCompanyService.getDetail(id);
			break;
		case SysConstant.FormType.CheckReason:
			data = CheckReasonService.getDetail(id);
			break;
		case SysConstant.FormType.CheckPlan:
			data = CheckPlanService.getDetail(id);
			break;
		case SysConstant.FormType.BusinessContract:
			data = BusinessContractService.getDetail(id);
			break;
		case SysConstant.FormType.ContractConfirm:
			data = BusinessContractService.getDetail(id);
			break;
		case SysConstant.FormType.FinancialReceived:
			data = BusinessFinancialReceivedService.getDetail(id);
			break;
		case SysConstant.FormType.FinancialBill:
			data = BusinessFinancialBillService.getDetail(id);
			break;
		case SysConstant.FormType.CheckDelivery:
			data = CheckDeliveryService.getDetail(id);
			break;
		case SysConstant.FormType.CheckChangDiao1:
			data = CheckCollectService.getDetail(id);
			break;
		case SysConstant.FormType.CheckChangDiao2:
			data = CheckCollectService.getDetail(id);
			break;
		case SysConstant.FormType.CheckCaiYang:
			data = CheckCollectService.getDetailProgress(id, SysConstant.FormType.CheckCaiYang);
			break;
		case SysConstant.FormType.CheckCaiYangDept:
			data = CheckCollectService.getDetail(id);
			break;
		case SysConstant.FormType.CheckShouYang:
			data = CheckCollectService.getDetailProgress(id, SysConstant.FormType.CheckShouYang);
			break;		
		case SysConstant.FormType.LibDispatch:
			data = CheckCollectService.getDetailProgress(id, SysConstant.FormType.LibDispatch);
			break;
		case SysConstant.FormType.LibAnalysis:
			data = CheckLibAnalysisService.getDetail(id);
			break;
		case SysConstant.FormType.LibReport:
			data = CheckCollectService.getDetailProgress(id, SysConstant.FormType.LibReport);
			break;
		case SysConstant.FormType.CheckReport:
			data = CheckCollectService.getDetail(id);
			break;
		case SysConstant.FormType.ShowPublic:
			data = CheckCollectService.getDetail(id);
			break;
		case SysConstant.FormType.CheckService:
			data = CheckCollectService.getDetailProgress(id, SysConstant.FormType.CheckService);
			break;
		case SysConstant.FormType.HandOver:
			data = CheckCollectService.getDetailProgress(id, SysConstant.FormType.HandOver);
			break;
		case SysConstant.FormType.CloseDept:
			data = CheckCollectService.getDetailProgress(id, SysConstant.FormType.CloseDept);
			break;
		case SysConstant.FormType.CloseFinancial:
			data = CheckCollectService.getDetailProgress(id, SysConstant.FormType.CloseFinancial);
			break;
		case SysConstant.FormType.Archive:
			data = CheckCollectService.getDetail(id);
			break;
		default:
			break;
		}
		return R.ok().data(data);
	}

	@Operation(summary = "工作流流程数据")
	@GetMapping("/getFlowData")
	public R getFlowData(Integer id, String type) {
		//log.debug("{}-工作流流程数据", info_prefix);
		WorkFlowObject data = WorkService.getWorkFlowObject(id, type);
		return R.ok().data(data);
	}

}
